package org.daemon.believe.mythink.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.daemon.believe.mythink.bean.BaseParam;
import org.daemon.believe.mythink.common.PageWrap;
import org.daemon.believe.mythink.mapper.UserInfoMapper;
import org.daemon.believe.mythink.model.UserInfo;
import org.daemon.believe.mythink.service.UserInfoService;
import org.springframework.stereotype.Service;


@Service
public class UserInfoServiceImpl implements UserInfoService{

	@Resource
	private UserInfoMapper userInfoMapper;
	
	
	public int addUserInfo(UserInfo userinfo) {
		return userInfoMapper.insertSelective(userinfo);
	}

	public int deleteUserInfoById(Long id) {
		return userInfoMapper.deleteByPrimaryKey(id);
	}

	public int updateUserInfo(UserInfo userinfo) {
		return userInfoMapper.updateByPrimaryKeySelective(userinfo);
	}

	public PageWrap<UserInfo> findPageUserInfo(UserInfo userinfo, int currentPage, int pageSize) {
		BaseParam param = new BaseParam();
		param.setId(userinfo.getId());
		param.setPageNumber(currentPage);
		param.setPageSize(pageSize);
		List<UserInfo> data = userInfoMapper.selectPageList(param);
		int total = userInfoMapper.countPageList(param);
		PageWrap<UserInfo> pw = new PageWrap<UserInfo>(currentPage, pageSize, total);
		pw.setRows(data);
		return pw;
	}

	
}
